<?php
require_once(ROOTDIR."/include/database/class.ServerQueries.php");

$id = $_GET['id'];
$name = $_GET['name'];
$ip = $_GET['ip'];
$port = $_GET['port'];
$type = $_GET['type'];
$rcon = $_GET['rcon'];

// Update the server status
$serverQueries = new ServerQueries();

$serverQueries->updateServer($name, $ip, $port, $rcon, $type, $id);

// Send back the new active state
header('Content-Type: text/xml');
header("Cache-Control: no-cache, must-revalidate");

function convertXmlSpecial($string) {
  $string = str_replace("&", "&amp;", $string);
  $string = str_replace("'", "&apos;", $string);
  $string = str_replace("\"", "&quot;", $string);
  $string = str_replace("<", "&lt;", $string);
  $string = str_replace(">", "&gt;", $string);
  return $string;
}

?>
<?echo "<?xml version=\"1.0\" ?>";?>
<root>
  <id><?=$id?></id>
	<name><?=convertXmlSpecial($name)?></name>
</root>
